#!/usr/bin/env bash

# Run in a proper install dune env.
case $1 in
    checker)
        shift
        exe=_build/default/checker/coqchk.bc
        ;;
    coqide)
        shift
        exe=_build/default/ide/coqide/coqide_main.bc
        ;;
    coqc)
        shift
        exe=_build/default/topbin/coqc_bin.bc
        ;;
    coqtop)
        shift
        exe=_build/default/topbin/coqtop_byte_bin.bc
        ;;
    *)
        echo "First argument must be one of {coqc,coqtop,checker,coqide}"
        exit 1
        ;;
esac

emacs="${INSIDE_EMACS:+-emacs}"

ocamldebug $emacs $(ocamlfind query -recursive -i-format coq.top_printers) -I +threads -I dev $exe "$@"
